package com.bill.pokerbe.service;

import com.bill.pokerbe.model.Card;
import com.bill.pokerbe.model.CardCommon;
import com.bill.pokerbe.model.CardType;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class CardService {
    private List<Card> cardList;
    int cardIndex = 0;

    public CardService() {
        cardList = new ArrayList<>();
        CardType[] cardTypes = CardCommon.CardTypeList();
        String[] cardNums = CardCommon.CardNumList();
        for (CardType cardType : cardTypes) {
            for (String cardNum : cardNums) {
                cardList.add(new Card(cardType, cardNum));
            }
        }
    }

    public void generateNewCardList() {
        cardIndex = 0;
        Collections.shuffle(cardList);
    }

    public Card getACard() {
        return cardList.get(cardIndex++);
    }

    public int getCardScore(List<Card> cardList) {
        return 0;
    }
}
